import React from 'react';
import avatar from '../images/avatar.png'
export class CommentList extends React.Component {
  render() {
    return (
      // 评论列表区
      <div className="comment-list">
        {this.props.list.map(item => {
          return (
            <div className="comment-item" key={item.id}>
              <div>
                <img className="user-head" src={avatar} alt="头像" />
              </div>
              <div className="comment">
                <div className="user">{item.author}</div>
                <p className="text">{item.comment}</p>
                <div className="info">
                  <span className="time">{JSON.stringify(item.time)}</span>
                  <span className={`like ${item.attitude === 1 ? 'liked' : ''}`} onClick={() => { this.props.changeAttitude(item.id, item.attitude === 1 ? 0 : 1) }}>
                    <i className="icon" />
                  </span>
                  <span className={`hate ${item.attitude === -1 ? 'hated' : ''}`} onClick={() => { this.props.changeAttitude(item.id, item.attitude === -1 ? 0 : -1) }}>
                    <i className="icon" />
                  </span>
                  <span className="btn-hover" onClick={() => this.props.delComment(item.id)}>删除</span>
                </div>
              </div>
            </div>
          )
        })}

      </div>
    )
  }
}